#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const int maxn = 1e6 + 100;


int main() {
    ll n;
    cin >> n;
    ll two = 0, five = 0;
    ll s = 1;
    for (ll i = 2; i <= n; i++) {
        ll j = i;
        while (j % 2 == 0) {
            j /= 2;
            ++two;
        }
        while (j % 5 == 0) {
            j /= 5;
            ++five;
        }
        s = (s * j) % 10;
    }
    for (int i = 0; i < two - five; i++) {
        s = (s * 2) % 10;
    }
    cout << s;

    return 0;
}